project(TaskApp)

# 开启Qt编译支持
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 配置生成的执行文件、静态库、动态库保存位置
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_LIB_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_LIB_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_BIN_DIR})

# 查找系统环境变量中Qt5或Qt6的库
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Widgets Gui Concurrent PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Gui Concurrent PrintSupport)

# 源文件列表
set(SRC_LIST
        main.cpp
        Universal/Universal.cpp
        Business/Business.cpp
        Assemblies/MainWidget/MainWidget.cpp
        Assemblies/SyntaxHighlighter/LuaSyntaxHighlighter.cpp
)

# 头文件列表
set(HEAD_LIST
        ../KernelDll/Base/SharedData.h
        Universal/Universal.h
        Business/Business.h
        Assemblies/MainWidget/MainWidget.h
        Assemblies/SyntaxHighlighter/LuaSyntaxHighlighter.h
)

set(UI_LIST
        Assemblies/MainWidget/MainWidget.ui
)

set(RES_LIST
        Resource/res.qrc
        Resource/rc/main.rc
)

# 生成可执行文件
add_executable(${PROJECT_NAME}
        ${SRC_LIST}
        ${HEAD_LIST}
        ${UI_LIST}
        ${RES_LIST}
)

# 连接库
target_link_libraries(${PROJECT_NAME}
        ${KITHARA_LIB}
        Qt${QT_VERSION_MAJOR}::Core
        Qt${QT_VERSION_MAJOR}::Gui
        Qt${QT_VERSION_MAJOR}::Widgets
        Qt${QT_VERSION_MAJOR}::Concurrent
        Qt${QT_VERSION_MAJOR}::PrintSupport
        #vld
)

# 设置编译选项
if (MSVC)
    if (CMAKE_BUILD_TYPE MATCHES "Release")
        set_target_properties(${PROJECT_NAME} PROPERTIES
                WIN32_EXECUTABLE TRUE
                #LINK_FLAGS "/ENTRY:mainCRTStartup /MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS"
                LINK_FLAGS "/ENTRY:mainCRTStartup"
                COMPILE_FLAGS "/EHsc"
        )
    endif ()
endif ()

